import md5
def sumfile(fobj):
    m = md5.new()
    while True:
        d = fobj.read(65536)
        if not d:
            break
        m.update(d)
    return m.hexdigest()
def md5sum(fname):
    try:
        f = file(fname, 'rb')
    except:
        return 'Failed to open file'
    ret = sumfile(f)
    f.close()
    return ret

